#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
struct Naruto{
    ll d, v, a;
}car[N];
struct Genshin{
    ll l, r;
}vis[N];
inline ll read() {
    ll x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
ll T, n, m, L, V, ans, num, s, l, r;
double vn;
ll p[N];
bool A, B, C;
signed main(void) {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    T = read();
    while (T--) {
        n = read(), m = read(), L = read(), V = read();
        ans = 0, num = 0;
        for (register int i = 1; i <= n; i++) {
            car[i].d = read(), car[i].v = read(), car[i].a = read();
            if (car[i].a != 0) A = true;
            if (car[i].a < 0) B = true;
            if (car[i].a > 0) C = true;
        }
        for (register int i = 1; i <= m; i++) p[i] = read();
        if (!A) {
            for (register int i = 1; i <= n; i++) {
                if (car[i].v > V) ans++;
            }
            printf("%lld %lld\n", ans, m - 1);
            continue;
        }
        if (!B) {
            for (register int i = 1; i <= n; i++) {
                for (register int j = 1; j <= m; j++) {
                    if (p[j] < car[i].d) continue;
                    s = p[j] - car[i].d;
                    vn = sqrt(car[i].v * car[i].v + 2 * car[i].a * s);
                    if (vn > V) {
                        ans++;
                        break;
                    }
                }
            }
            printf("%lld %lld\n", ans, m - 1);
            continue;
        }
        if (!C) {
            cout << "RP++" << endl;
            continue;
        }
        cout << "RP++" << endl;
    }
    return 0;
}
